package views;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.example.zx.theline.R;

import GsonBean.ZszjhBean;

/**
 * Created by Ren on 2017/7/27.
 */

public class ZszjhView extends RelativeLayout {

    LinearLayout view;
    FrameLayout tablelayout;

    ZszjhBean.RowsBean mZszjhBean;

    //是否已经是多选布局
    int isGroupDoneLayout = 0;


    //周计划号
    TextView zjhh;
    //施工日期
    TextView sgrq;
    //类别
    TextView lb;
    //线名
    TextView xm;
    //行别
    TextView hb;
    //施工地点
    TextView sgdd;
    //施工项目
    TextView sgxm;
    //施工内容
    TextView sgnr;
    //施工机械
    TextView sgjx;
    //B类防护
    TextView blfh;
    //施工单位
    TextView sgdw;
    //状态
    TextView zt;
    //操作按钮图片
    TextView mImageView;

    //B类防御layout
    LinearLayout layout_blfh;


    public ZszjhView(Context context, boolean isGroupDone) {
        super(context);
        initView();
        initDate();
        initListen();
    }

    public ZszjhView(Context context, AttributeSet attrs) {
        super(context, attrs);
        initView();
        initDate();
        initListen();
    }

    public ZszjhView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        initView();
        initDate();
        initListen();
    }


    private void initView() {
        view = (LinearLayout) inflate(getContext(), R.layout.zszjhview, null);
        addView(view);

        zjhh = (TextView) findViewById(R.id.zjhh);
        sgrq = (TextView) findViewById(R.id.sgrq);
        lb = (TextView) findViewById(R.id.lb);
        layout_blfh = (LinearLayout) findViewById(R.id.layout_blfh);
        xm = (TextView) findViewById(R.id.xm);
        hb = (TextView) findViewById(R.id.hb);
        sgdd = (TextView) findViewById(R.id.sgdd);
        sgxm = (TextView) findViewById(R.id.sgxm);
        sgnr = (TextView) findViewById(R.id.sgnr);
        sgjx = (TextView) findViewById(R.id.sgjx);
        blfh = (TextView) findViewById(R.id.blfh);
        sgdw = (TextView) findViewById(R.id.sgdw);
        mImageView = (TextView) findViewById(R.id.mImageView);
        tablelayout = (FrameLayout) findViewById(R.id.tablelayout);
//                mViewHolder.zt = (TextView) convertView.findViewById(R.id.zt);
    }

    private void initDate() {

    }

    private void initListen() {

        mImageView.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {

            }
        });
    }

    public void setDate(ZszjhBean.RowsBean mZszjhBean) {
        this.mZszjhBean = mZszjhBean;
        zjhh.setText(mZszjhBean.getBh());
        sgrq.setText(mZszjhBean.getExsgrq());
        lb.setText(mZszjhBean.getLb() + "类");
        if (mZszjhBean.getLb().equals("B")) {
            lb.setTextColor(getResources().getColor(R.color.colorTextB));
        } else if (mZszjhBean.getLb().equals("C")) {
            lb.setTextColor(getResources().getColor(R.color.colorTextC));
        }
        xm.setText(mZszjhBean.getXlmc());
        hb.setText(mZszjhBean.getXbmc());
        sgdd.setText(mZszjhBean.getSgdd());
        sgxm.setText(mZszjhBean.getXmmc());
        sgnr.setText(mZszjhBean.getNrmc());
        sgjx.setText(mZszjhBean.getJxmc());
        blfh.setText(mZszjhBean.getBlfhmc());
        sgdw.setText(mZszjhBean.getSgdwmc());
    }

    public void showLayoutProtectB() {
        layout_blfh.setVisibility(VISIBLE);
    }

    public void hideLayoutProtectB() {
        layout_blfh.setVisibility(GONE);
    }

}

